package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.api.domain.response.ProjectMemberResponse;
import com.nbsaas.boot.project.data.entity.ProjectMember;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
/**
 * 项目成员-实体对象转化成响应对象
 */

public class ProjectMemberResponseConvert implements Converter<ProjectMemberResponse, ProjectMember> {

    @Override
    public ProjectMemberResponse convert(ProjectMember source) {
        ProjectMemberResponse result = new ProjectMemberResponse();
        BeanDataUtils.copyProperties(source, result);
        if (source.getMember() != null) {
            result.setMember(source.getMember().getId());
        }
        if (source.getProject() != null) {
            result.setProject(source.getProject().getId());
        }

        try {
            if (source.getMember() != null) {
                result.setMemberName(source.getMember().getName());
            }
        } catch (Exception ignored) {
        }


        try {
            if (source.getProject() != null) {
                result.setProjectName(source.getProject().getName());
            }
        } catch (Exception ignored) {
        }

        return result;
    }

}

